package com.suntek.svn.utils.comparator;

import java.util.Comparator;

public class AuthenComparator implements Comparator<String> {
	public int compare(String o1, String o2) {
		String key1 = o1.split("=")[0];
		String key2 = o2.split("=")[0];
		if (key1.equals("*") && !key2.equals("*")) {
			return -1;
		} else if (!key1.equals("*") && key2.equals("*")) {
			return 1;
		} else {
			if (key1.startsWith("@") && !key2.startsWith("@")) {
				return -1;
			} else if (!key1.startsWith("@") && key2.startsWith("@")) {
				return 1;
			} else {
				char a1 = key1.charAt(0);
				char a2 = key2.charAt(0);
				if (a1 < a2) {
					return -1;
				} else if (a1 == a2) {
					return 0;
				} else {
					return 1;
				}
			}
		}
	}
}
